package com.anjie.powerproject.repository;

import com.anjie.powerproject.entity.PredictData;
import com.anjie.powerproject.entity.PredictElectricity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

public interface PredictDataRepository extends JpaRepository<PredictData,Integer> {

    @Query(nativeQuery = true,value = "select * from predict_data pd where sdate(pd.sdate) = cursdate()")
    List<PredictData> findPredictDataByDeviceId();

    @Query(nativeQuery = true,value = "select * from predict_data pd order by pd.sdate desc limit 1")
    PredictData getPredictDataByDate();

    /*@Query(nativeQuery = true,value = "select * from predict_data pd where pd.predict_device_id = ?1 order by pd.sdate desc limit 1")
    PredictData getPredictDataByDateAndDEiveId(Integer deviceId);*/

    /*@Query(nativeQuery = true,value = "select * from predict_data pd where DATE_FORMAT(pd.sdate,'%Y-%m-%d')=?1 and pd.predict_device_id = ?2")
    PredictData findPredictDataByDateAndDayAnId(String day,Integer id);*/

    @Query(nativeQuery = true,value = "select * from predict_data pd where DATE_FORMAT(pd.sdate,'%Y-%m-%d')=?1 and pd.graph_id = ?2 and stgy_type = ?3")
    PredictData findPredictDataByDateAndDayAnId(String day,Integer graphId,Integer stgyType);

    // todo 这里要修改
    @Query(nativeQuery = true, value = "select * from predict_data limit 1")
    PredictData getSelectedPredictEnergy();
}
